package com.wei.frame.framework;

import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.OnLifecycleEvent;

import com.wei.frame.integration.IRepositoryManager;

/**
 * 作者：赵若位
 * 时间：2020/12/22 21:30
 * 祈祷：佛祖保佑，永无Bug~
 * 功能：
 */
public class BaseModel implements LifecycleObserver {

    private IRepositoryManager mIRepositoryManager;


    public BaseModel(IRepositoryManager IRepositoryManager) {
        mIRepositoryManager = IRepositoryManager;
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
    public void onDestroy(LifecycleOwner owner) {
        mIRepositoryManager = null;
        if (null != owner) {
            owner.getLifecycle().removeObserver(this);
        }
    }
}
